home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / doom / suckmods.zip / SUCKMODS.ZIP / suck05 / src / hook.qc < prev    next >
Text File  |  1997-05-09  |  7KB  |  267 lines

  1. // prototypes
  2. void(entity e, float chan, string samp, float vol, float atten) playsound;
  3.  
  4. /************\
  5. * BreakChain *
  6. \************/
  7.  
  8. void (entity Head) BreakChain =
  9. {
  10.         local entity link;
  11.  
  12.         link = Head.goalentity;
  13.         while (link != world)
  14.         {
  15.                 Head = link.goalentity;
  16.                 remove (link);
  17.                 link = Head;
  18.         }
  19. };
  20.  
  21. /*********\
  22. * LinkPos *
  23. \*********/
  24.  
  25. void () LinkPos =
  26. {
  27.         makevectors (self.enemy.angles);
  28.         setorigin (self, self.owner.origin + ( ( ( self.enemy.origin + 
  29.                 (v_up * 16 * (!self.enemy.button2)) + (v_forward * 16) ) - self.owner.origin ) *
  30.                 ( self.weapon ) ) );
  31.         self.nextthink = time + 0.1;
  32. };
  33.  
  34. /***********\
  35. * MakeChain *
  36. \***********/
  37.  
  38. entity (entity head, entity tail, float num) MakeChain =
  39. {
  40.         local entity link, prevlink;
  41.         local float linknum;
  42.  
  43.         linknum = num;
  44.         num = num + 1;
  45.         prevlink = world;
  46.         while (linknum > 0)
  47.         {
  48.                 link = spawn();
  49.  
  50.                 link.goalentity = prevlink;
  51.                 prevlink = link;
  52.  
  53.                 link.owner = head;
  54.                 link.enemy = tail;
  55.                 link.weapon = linknum / num;
  56.                 link.movetype = MOVETYPE_NOCLIP;
  57.                 link.solid = SOLID_NOT;
  58.                 link.angles_z = 51 * linknum;
  59.                 link.angles_y = 41 * linknum;
  60.                 link.angles_x = 31 * linknum;
  61.                 link.avelocity = '310 410 510';
  62.                 if (teamplay & TEAM_CAPTURE_CUSTOM)
  63.                     setmodel (link, "progs/bit.mdl");
  64.                 else
  65.                     setmodel (link, "progs/s_spike.mdl");
  66.                 setsize (link, '0 0 0', '0 0 0');
  67.                 makevectors (tail.angles);
  68.                 setorigin (link, head.origin + ( ( ( tail.origin 
  69.                         + (v_up * 16 * (!tail.button2)) + ( v_forward * 16 ) ) - head.origin )
  70.                         * ( link.weapon ) ) );
  71.                 link.nextthink = time + 0.1;
  72.                 link.think = LinkPos;
  73.                 linknum = linknum - 1;
  74.         }
  75.         return link;
  76. };
  77.  
  78.  
  79. /************\
  80. * HookVanish *
  81. \************/
  82.  
  83. void () HookVanish =
  84. {
  85.         self.owner.hook_out = FALSE;
  86. /*
  87.         if (self.enemy.classname == "player")
  88.                 self.enemy.attack_finished = time + 0.1;
  89. */
  90.         if (teamplay & TEAM_CAPTURE_CUSTOM)
  91.             playsound(self.owner, CHAN_WEAPON, "weapons/bounce2.wav", 1, ATTN_NONE);
  92.         BreakChain (self);
  93.         remove (self);
  94. };
  95.  
  96. /**********\
  97. * HookPull *
  98. \**********/
  99.  
  100. void () HookPull =
  101. {
  102.         local vector vel, spray;
  103.         local float v, dorg;
  104.  
  105.     if ((!self.owner.button0 && (self.owner.weapon == IT_HOOK)) ||
  106.         (self.owner.teleport_time > time ) || self.owner.deadflag ) {
  107.         HookVanish();
  108.         return;
  109.     } else {
  110.          if (self.enemy.takedamage) {
  111.             // don't hurt teammates
  112.             if (self.enemy.classname != "player" || !teamplay ||
  113.                 self.enemy.lastteam != self.owner.lastteam) {
  114.                 playsound (self, CHAN_WEAPON, "blob/land1.wav", 1, ATTN_NORM);
  115. //                T_Damage (self.enemy, self, self.owner, 1);
  116.                 makevectors (self.v_angle);
  117.                 spray_x = 100 * crandom();
  118.                 spray_y = 100 * crandom();
  119.                 spray_z = 100 * crandom() + 50;
  120. //                SpawnBlood (self.origin, spray, 73, 20);
  121.             }
  122.             if (self.enemy.solid == SOLID_SLIDEBOX) {
  123.                     self.velocity = '0 0 0';
  124.                     setorigin (self, self.enemy.origin +
  125.                             self.enemy.mins +
  126.                             (self.enemy.size * 0.5));
  127.             } else {
  128.                     self.velocity = self.enemy.velocity;
  129.             }
  130.         } else {
  131.                 self.velocity = self.enemy.velocity;
  132.         }
  133.         if (self.enemy.solid == SOLID_NOT) {
  134.                 HookVanish();
  135.                 return;
  136.         }
  137.         makevectors (self.owner.angles);
  138.         vel = self.origin - ( self.owner.origin + (v_up * 16 *
  139.                 (!self.owner.button2)) + (v_forward * 16));
  140.         v = vlen (vel);
  141.         if (v <= 100)
  142.                 vel = normalize(vel) * v * 10;  
  143.         if ( v > 100 )
  144.                 vel = normalize(vel) * 1000;  
  145.  
  146.         if (teamplay & TEAM_CAPTURE_CUSTOM) {
  147.             dorg = vlen(self.owner.origin - self.dest);
  148.             if (dorg > 10 && self.style == 3) {
  149.                 playsound(self.owner, CHAN_WEAPON, "weapons/chain2.wav", 1, ATTN_NORM);
  150.                 self.style = 2;
  151.             }
  152.             if (dorg < 10 && self.style == 2) {
  153.                 playsound(self.owner, CHAN_WEAPON, "weapons/chain3.wav", 1, ATTN_NORM);
  154.                 self.style = 3;
  155.             }
  156.         }
  157.  
  158.         self.owner.velocity = vel;
  159.         self.dest = self.owner.origin;
  160.         self.nextthink = time + 0.1;
  161.     }
  162. };
  163.  
  164. /**************\
  165. * T_ChainTouch *
  166. \**************/
  167.  
  168. void() T_ChainTouch =
  169. {
  170.     if (other == self.owner)
  171.             return;         // don't attach to owner
  172.  
  173.     if (other.classname == "player" && other.rune_num == ITEM_RUNE_ALIBABA)
  174.     {    
  175.         HookVanish();
  176.         return;
  177.     }
  178.  
  179.     if (pointcontents(self.origin) == CONTENT_SKY) {
  180.                 HookVanish();
  181.                 return;
  182.     }
  183.  
  184.     if (other.classname == "player" && teamplay &&
  185.         other.team == self.owner.lastteam)
  186.         return; // just pass through teammates
  187.  
  188.     if (other.takedamage) {
  189.         // don't damage teammates
  190.         if (other.classname == "player")
  191.             other.axhitme = 1; // make axe noise
  192.         else
  193.             playsound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  194. //        T_Damage (other, self, self.owner, 10 );
  195. //        SpawnBlood (self.origin, self.velocity, 73, 10);
  196.     } else {
  197.         playsound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  198.         self.avelocity = '0 0 0';
  199.     }
  200.                 
  201.     if (!self.owner.button0) {
  202.             HookVanish();
  203.             return;
  204.     } else {
  205.             if (other.solid == SOLID_SLIDEBOX) {
  206.                     setorigin (self, other.origin + other.mins +
  207.                             (other.size * 0.5));
  208.                     self.velocity = '0 0 0';
  209.             } else {
  210.                     self.velocity = other.velocity;
  211.             }
  212.             self.weapon = other.nextthink - time;
  213.             if (teamplay & TEAM_CAPTURE_CUSTOM)
  214.                 playsound (self.owner, CHAN_WEAPON, "weapons/chain2.wav", 1, ATTN_NORM);
  215.  
  216.             self.style = 2;
  217.             self.enemy = other;
  218.             self.nextthink = time + 0.1;
  219.             self.think = HookPull;
  220.             self.touch = SUB_Null;
  221.     }
  222. };
  223.  
  224. /*************\
  225. * W_FireChain *
  226. \*************/
  227.  
  228. void() W_FireChain =
  229. {
  230.         local entity hook;
  231.  
  232.         self.hook_out = TRUE;
  233.         hook = spawn ();
  234.         hook.owner = self;
  235.         hook.movetype = MOVETYPE_FLY;
  236.         hook.solid = SOLID_BBOX;
  237.         
  238. // set hook speed 
  239.  
  240.         makevectors (self.v_angle);
  241.         hook.velocity = aim(self, 1000);
  242.         hook.velocity = hook.velocity * 800;
  243.         hook.angles = vectoangles(hook.velocity);
  244.         hook.avelocity = '0 0 -500';
  245.     
  246.         hook.touch = T_ChainTouch;
  247.     
  248. // set hook sound
  249.         hook.nextthink = time + 20;
  250.         hook.think = HookVanish;
  251.  
  252.         if (teamplay & TEAM_CAPTURE_CUSTOM)
  253.             setmodel (hook, "progs/star.mdl");
  254.         else
  255.             setmodel (hook, "progs/v_spike.mdl");
  256.         setsize (hook, '0 0 0', '0 0 0');     
  257.         setorigin (hook, self.origin + (v_forward*16) + '0 0 16' );
  258.  
  259.         if (teamplay & TEAM_CAPTURE_CUSTOM)
  260.             playsound (self, CHAN_WEAPON, "weapons/chain1.wav", 1, ATTN_NORM);    
  261.         else
  262.             playsound (self, CHAN_WEAPON, "hknight/hit.wav", 1, ATTN_NORM);    
  263.  
  264.         hook.goalentity = MakeChain (hook, self, 3);
  265. };
  266.  
  267.